using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.SqlClient;
using System.Data;
using System.Collections;
using System.Drawing;
using System.Drawing.Drawing2D;
using DataAccess;

namespace BusinessLogic
{
    public class TimKiemNhanVien : MarshalByRefObject
    {
        private static SqlCommand cmd;
        private static ArrayList arr;
        private static SqlDataReader dr;
        private static SqlConnection cn;



        // Selct khách hàng
        public static Entities.TimKiemNhanVien[] Select()
        {
            Entities.TimKiemNhanVien[] list = null;
            try
            {
                string sql = Common.Constants.TimKiemNhanVien.SelectTimKiemNhanVien;
                cn = DataAccess.Connection.OpenConnection();
                cmd = new SqlCommand(sql, cn);
                dr = cmd.ExecuteReader(CommandBehavior.CloseConnection);
                arr = new ArrayList();
                while (dr.Read())
                {
                    Entities.TimKiemNhanVien nhanvien = new Entities.TimKiemNhanVien();
                    nhanvien.MaNhanVien = dr[Common.Constants.TimKiemNhanVien.MaNhanVien].ToString();
                    nhanvien.TenNhanVien = dr[Common.Constants.TimKiemNhanVien.TenNhanVien].ToString();
                    nhanvien.DCThuongTru = dr[Common.Constants.TimKiemNhanVien.DCThuongTru].ToString();

                 
                    arr.Add(nhanvien);
                }
                int n = arr.Count;
                if (n == 0)
                {
                    list = new Entities.TimKiemNhanVien[0];
                }
                else
                {
                    list = new Entities.TimKiemNhanVien[n];
                    for (int i = 0; i < n; i++)
                    {
                        list[i] = (Entities.TimKiemNhanVien)arr[i];
                    }
                }
                return list;
            }
            catch (Exception ex)
            { string s = ex.Message.ToString(); return new Entities.TimKiemNhanVien[0]; }
            finally
            {
                cmd.Connection.Dispose();
                cn.Close();
            }

        }


    }
}
